package base.study.postgresql;

import org.postgresql.ds.PGSimpleDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * TODO(用一句话描述方法的主要功能)
 */
public class Demo1 {

    public static void main(String[] args) throws SQLException {

        String url = "jdbc:postgresql://43.136.94.164:5432/mydb";
        String username = "postgres";
        String password = "abc123Qaz";
        Connection connection = DriverManager.getConnection(url, username, password);

        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from weather");
        while(resultSet.next()){
            String city = resultSet.getString("city");
            System.out.println(city);
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
